#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string>
#include <strings.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h> 
#include <sys/socket.h>
#include <sys/wait.h>
#include <netinet/in.h>
#include <netdb.h>
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
#include <vector>


#include "Alfred.h"


#define BUFFER_SIZE 1024

enum ACK		{ WELCOME, OK, MOVE, ILLEGAL, comment, whitewin, blackwin};
enum MODE		{ HUMAN_AI, AI_AI };

class Server
{

	private:
		int sockfd;

		int server_sockfd;
		int server_port;
		string server_addr;
		 
		bool		display;
		MODE		game_play;
		bool		turn;

		Game game;
		Alfred al;
		
		void connect_server();

	public:
		
		Server():				sockfd(0), display(false), 
								game_play(HUMAN_AI),turn(false), game(), al(HARD, WHITE, &game)
								{};

		Server(int new_sockfd): sockfd(new_sockfd), display(false), 
								game_play(HUMAN_AI),turn(false), game(), al(HARD, WHITE,&game) 
								{};
		~Server(){};

		void toggle_display();
		void set_difficulty(string val);
		void send_ack(ACK a);
		int make_move(string move);
		bool validate_move(string move);
		bool parse(vector<string> message);
		void run();
		void shutdown(int sock);
};
